import request from '@/utils/request'
import type { responseCategoryData, responseAttrInfoData } from './type'
enum API {
  Category1_URL = '/admin/product/getCategory1',
  CATEGORY2_URL = '/admin/product/getCategory2/',
  CATEGORY3_URL = '/admin/product/getCategory3/',
  ATTRINFOLIST_URL = '/admin/product/attrInfoList/',
  ADDORUPDATEATTR_URL = '/admin/product/saveAttrInfo',
  DELETEATTR_URL = '/admin/product/deleteAttr/'
}
export const reqCategory1 = () => {
  return request.get<any, responseCategoryData>(API.Category1_URL)
}
export const reqCategory2 = (category1Id: string) => {
  return request.get<any, responseCategoryData>(API.CATEGORY2_URL + `${category1Id}`)
}
export const reqCategory3 = (category2Id: string) => {
  return request.get<any, responseCategoryData>(API.CATEGORY3_URL + `${category2Id}`)
}
export const reqAttrInfoList = (category1Id: string, category2Id: string, category3Id: string) => {
  return request.get<any, responseAttrInfoData>(
    API.ATTRINFOLIST_URL + `${category1Id}/${category2Id}/${category3Id}`
  )
}
export const reqAddOrUpdateAttr = (data: any) => {
  return request.post<any, any>(API.ADDORUPDATEATTR_URL, data)
}
export const reqDeleteAttr = (attrId: number) => {
  return request.delete(API.DELETEATTR_URL + `${attrId}`)
}
